let GpsService = require('../service/GpsService');

function uploadPosition(context, json) {
	GpsService.uploadPosition(json)
		.then((data) => context.finish(data))
		.catch((error) => context.processError(error));
}

function direct(context, gpsNo, directState, protocolNo, factoryCode, type, directCode, remark) {
	GpsService.direct(gpsNo, directState, protocolNo, factoryCode, type, directCode, remark)
		.then((data) => context.finish(data))
		.catch((error) => context.processError(error));
}

function getPositionOfLatest(context, gpsNo) {
	GpsService.getPositionOfLatest(gpsNo)
		.then((data) => context.finish(data))
		.catch((error) => context.processError(error));
}

function getPositionOfPeriod(context, gpsNo, startTime, endTime) {
	GpsService.getPositionOfPeriod(gpsNo, startTime, endTime)
		.then((data) => context.finish(data))
		.catch((error) => context.processError(error));
}

let Gps = {
	uploadPosition: uploadPosition,
	direct: direct,
	getPositionOfLatest: getPositionOfLatest,
	getPositionOfPeriod: getPositionOfPeriod
};

module.exports = Gps;